<?php

// +----------------------------------------------------------------------
// | Apprh.Shop
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2027 http://www.apprh.com All rights reserved.
// +----------------------------------------------------------------------
// | Notice: This code is not open source, it is strictly prohibited
// |         to distribute the copy, otherwise it will pursue its
// |         legal responsibility.
// +----------------------------------------------------------------------
// | Author: 雲溪荏苒 <290648237@qq.com>
// +----------------------------------------------------------------------

namespace app\frontend\controller;

use controller\HomeBase;


/**
 * 网站前端入口控制器
 * Class Index
 * @package app\frontend\controller
 * @author 雲溪荏苒 <290648237@qq.com>
 * @date 2017/12/9
 */
class Index extends HomeBase
{

    /**
     * 网站首页
     * @return mixed
     */
    public function index()
    {

        $this->assign('generator', request()->domain().'/,cn,10001,,10001,M1156010');
        $this->assign('body_class', 'class-10001');

        // 获取关于我们
        $about = model('article')->getArticleDetailById(1);
        $about['article_content'] = strip_tags($about['article_content']); // 过滤html标签
        $this->assign('about', $about);

        // 获取产品分类列表
        $productClassList = model('product_class')->getList(['status'=>1],'sort asc', '*', 0, 4);
        $this->assign('productClassList', $productClassList);

        // 获取全部产品
        $allProductList = model('product')->getProductList(0, 12, true);
        $this->assign('allProductList', $allProductList);
        // 根据分类id获取产品
        $productList = model('product')->getProductList(4, 12);
        $this->assign('productList', $productList);

        // 获取视频列表
        list($videoList, $videoCount) = model('video')->getList(['status' => 1], 0, 12);
        $this->assign('videoList', $videoList);
        $firstVideo = [];
        if (!empty($videoList)) {
            $firstVideo = $videoList[0];
        }
        $this->assign('firstVideo', $firstVideo);

        // 获取案例分类列表
        $siteIndustryList = db('site_industry')->where('status', 1)->order('sort asc')->limit(0,4)->select();
        $this->assign('siteIndustryList', $siteIndustryList);

        // 获取全部案例
        $allCaseList = model('site_case')->getSiteCaseByCate(0, 12, true);
        $this->assign('allCaseList', $allCaseList);
        // 根据分类id获取案例
        $caseList = model('site_case')->getSiteCaseByCate(4, 12);
        $this->assign('caseList', $caseList);

        // 获取新闻分类列表 只获取一级分类
        $newsClassList = db('cms_article_class')->where(['pid' => 0])->order('class_sort asc')->limit(0, 4)->select();
        $this->assign('newsClassList', $newsClassList);
        // 获取所有新闻的一条推荐
        $allRecInfo = db('cms_article')->where(['article_state' => 3, 'article_commend_flag' => 1])
            ->order('article_click desc')->find();
        $this->assign('allRecInfo', $allRecInfo);
        // 根据分类id获取一条推荐新闻
        $recInfo = model('cms_article')->getRecNewsByCate(4, 1);
        $this->assign('recInfo', $recInfo);
        // 获取全部新闻
        $allNewsList = model('cms_article')->getNewsByCate(0, 12, true);
        $this->assign('allNewsList', $allNewsList);
        // 根据分类id获取新闻
        $newsList = model('cms_article')->getNewsByCate(4, 12);
        $this->assign('newsList', $newsList);

        // SEO
        $this->assign('seo_title', '首页 - '.sysconf('seo_title'));
        $this->assign('seo_keywords', sysconf('seo_keywords'));
        $this->assign('seo_description', sysconf('seo_description'));

        return $this->fetch('');
    }

}
